# -*- coding: utf-8 -*-
import unittest
from 第六次作业.query import Query

query = Query()
menu = '西红柿'
pn = 10
rn = 3


class QueryTest(unittest.TestCase):


    def test_assertEqual(self):
        q = query.get_query(menu, pn, rn)
        self.assertEqual('Success', q['reason'])

    def test_assertIsNotNone(self):
        q = query.get_query(menu, pn, rn)
        self.assertIsNotNone(q['result'])

    def test_assertIn(self):
        q = query.get_query(menu, pn, rn)
        self.assertIn('西红柿卤', q['result']['data'][0]['title'])

    def test_assertEqual_error(self):
        q = query.get_query('不存在的食物', pn, rn)
        self.assertEqual('Success', q['reason'])

    def test_assertIn_error(self):
        q = query.get_query(menu, pn, rn)
        self.assertIn('水', q['result']['data'][0]['title'])


if __name__ == '__main__':
    unittest.main()
